package com.idroc.storage.support;

import com.idroc.storage.IoBlock;
import com.idroc.storage.IoBlockFile;

/**
 * 只读IO块
 * @author yuyoo (yuyoo4j@163.com)
 * @date 2010-3-27 下午05:16:01
 */
public class ReadOnlyIoBlock implements IoBlock {

	/**
	 * 内部IO块, 被包装的IO块
	 */
	IoBlock inner = null;
	
	/**
	 * 构造一个只读的块
	 * @param inner
	 */
	public ReadOnlyIoBlock(IoBlock inner) {
		
		this.inner = inner;
	}
	
	public int size() { 
		
		return inner.size();
	}

	public boolean sync() { 
		
		return inner.sync();
	}

	public void write(int pos, byte value) {

		throw new UnsupportedOperationException("尝试对只读的IO块设置数据异常");
	}

	public void write(int pos, byte[] values) {

		throw new UnsupportedOperationException("尝试对只读的IO块设置数据异常");
	}

	public void writeInt(int pos, int value) {

		throw new UnsupportedOperationException("尝试对只读的IO块设置数据异常");
	}

	public void writeLong(int pos, long value) {

		throw new UnsupportedOperationException("尝试对只读的IO块设置数据异常");
	}

	public void writeShort(int pos, short value) {

		throw new UnsupportedOperationException("尝试对只读的IO块设置数据异常");
	}

	public byte[] array() {
		
		return inner.array();
	}

	public int arrayOffset() { 
		
		return inner.arrayOffset();
	}

	public IoBlockFile getIoBlockFile() {
		 
		return inner.getIoBlockFile();
	}

	public long getOffset() {
		 
		return inner.getOffset();
	}

	public boolean isDirty() {
		 
		return false;
	}

	public boolean load() {
		 
		return inner.load();
	}

	public byte read(int pos) {
		 
		return inner.read(pos);
	}

	public byte[] readBytes(int pos, int length) {

		return inner.readBytes(pos, length);
	}

	public int readInt(int pos) {

		return inner.readInt(pos);
	}

	public long readLong(int pos) {

		return inner.readLong(pos);
	}

	public short readShort(int pos) {

		return inner.readShort(pos);
	}

	public void wrap(byte[] data, int offset) {

		inner.wrap(data, offset);
	}

}
